from django.contrib.auth import get_user_model
from django.db import models

from answer.models import Answer
from questions.models import Question

User = get_user_model()


class Comment(models.Model):
    content = models.TextField(blank=True)

    creator = models.ForeignKey(User, related_name='comments', on_delete=models.CASCADE)

    question = models.ForeignKey(Question, related_name='comments', on_delete=models.CASCADE, null=True)
    answer = models.ForeignKey(Answer, related_name='comments', on_delete=models.CASCADE, null=True)

    created_time = models.DateTimeField(auto_now_add=True)
